package lab03.test08;

import lab04.test03.B;

import java.io.*;

/**
 * Created by 林云志 on 2017/12/13.
 */
public class Test {
    public static void main(String[] args) {
        /*
        * 8、	将文件一和文件二的内容合并成文件三，合并方法是：
        * 从文件一读取一个字节放入文件三，再从文件二读取一个字节放入文件三，
        * 如此轮流直至某一个文件读完，再将较长文件中的剩余部分读取放入至文件三。*/
        String path = "D:/Book.txt";
        String path1 = "D:/Book1.txt";
        String path2 = "D:/test.txt";
        try {
            FileInputStream fileInputStream = new FileInputStream(path);
            FileInputStream fileInputStream1 = new FileInputStream(path1);
            FileOutputStream fileOutputStream = new FileOutputStream(path2);
            int content = 1;
            int content1 = 1;

            while ((content = fileInputStream.read())!=-1||((content1 = fileInputStream1.read())!=-1)){
                fileOutputStream.write(content);
                fileOutputStream.write(content1);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
